<template>
	<view>
		<uni-nav-bar statusBar @clickLeft='clickLeft()' @clickRight="clickRight(0)" :border='border' color="#000000"
			fixed backgroundColor='#FFFFFF00' left-icon="left">
			<block slot="left">
				<image style="margin-right: 30rpx;width: 56rpx;height: 56rpx; border-radius: 50%;"
					src="../../static/common/logo.png" mode=""></image>
			</block>

			<view class="input-view flex-row-center" @click="handleLocation()">
				<view class="navTitle" style="text-align: center;">{{ylInfo.city}}</view>

			</view>
		</uni-nav-bar>
		<view class="topView">
			<view class="topView1"></view>
			<view class="title">
				Hi,您好！明途出行很高兴为您服务！
			</view>
			<u-tabs :current="tabsIndex" @click="tabClick" style="background-color: #FFFFFF00;" :list="tabsList"
				lineWidth="10" lineColor="#26D360" :activeStyle="{
											color: '#666666',
											
											transform: 'scale(1.05)'
										}" :inactiveStyle="{
											color: '#666666',
											transform: 'scale(1)'
										}" itemStyle="  height: 44px;width:50%;">
			</u-tabs>
			<view style="height: 10rpx;"></view>
			<swiper :autoplay="true" :interval="3000" :duration="1000" style="width: 750rpx;height: 266rpx;">
				<view v-for="(item,index) in slideshowList" :key="index">
					<swiper-item style="width: 750rpx;height: 266rpx;">
						
						<image :src="item" style="width: 750rpx;height: 266rpx;" mode="aspectFill"></image>
					</swiper-item>
				</view>
			
			</swiper>
			<view v-if="tabsIndex==0" class="view1">
				<view class="flex-row-space-between">
					<view class="flex-row-flex-start">

					</view>
					<!-- <view @click="show=true" class="flex-row-flex-start">
						<image class="image1" src="/static/index/1.png" mode=""></image>
						<view class="num">
							<text class="baseColor" style="margin-right: 6rpx;">{{num}}</text>
							<text>名司机</text>
						</view>
						<image class="image2" src="/static/index/2.png" mode=""></image>
					</view> -->
					<view @click="descriptionClick()" class="flex-row-flex-end">
						<view class="money">
							起步价：{{startPrice.start_price||'0'}}元
						</view>
						<image class="image3" src="/static/index/3.png" mode=""></image>
					</view>
				</view>
				<view class="flex-row-space-between">
					<view class=" flex1">
						<view @click="addressClick(0)" class="addressView flex-row-flex-start">
							<image class="image4" src="/static/index/4.png" mode=""></image>
							<view class="address flex1">
								<text>{{qdInfo.address?qdInfo.address:"您在哪里?"}}</text>

							</view>
						</view>
						<view @click="addressClick(1)" class="addressView flex-row-flex-start">
							<image class="image4 " src="/static/index/5.png" mode=""></image>
							<view class="address flex1">
								<text>{{zdInfo.address?zdInfo.address:"您要去哪?"}}</text>
							</view>
						</view>
					</view>
					<image @click="exchange('dache')" class="image6" src="/static/index/6.png" mode=""></image>
				</view>
				<view class="flex-row-space-between">
					<view @click="passengerInfoClick()" class="button flex-row-center">
						帮朋友叫
					</view>
					<view @click="orderDetailClick()" class="button1 flex-row-center">
						呼叫司机
					</view>
				</view>
			</view>

			<view v-if="tabsIndex==1" class="view1">

				<view class="flex-row-space-between">
					<view class=" flex1">
						<view @click="changePathCity('start')" class="addressView flex-row-flex-start">
							<image class="image4" src="/static/index/4.png" mode=""></image>
							<view class="address flex1">
								<text v-if="tailwindQdInfo.id">{{tailwindQdInfo.city}}</text>
								<text v-else>您在哪里?</text>

							</view>
						</view>
						<view @click="changePathCity('end')" class="addressView flex-row-flex-start">
							<image class="image4 " src="/static/index/5.png" mode=""></image>
							<view class="address flex1">
								<text v-if="tailwindZdInfo.id">{{tailwindZdInfo.city}}</text>
								<text v-else>您要去哪?</text>
								<!-- <text>{{tailwindZdInfo.address?tailwindZdInfo.address:"您要去哪?"}}</text> -->
							</view>
						</view>
					</view>
					<!-- <image @click="exchange('shunfeng')" class="image6" src="/static/index/6.png" mode=""></image> -->
				</view>
				<view class="flex-row-space-between">

					<view @click="findHitchRide" class="button2 flex-row-center">
						寻找车辆
					</view>
				</view>
		
			</view>
			<view v-if="tabsIndex==1" class="view1">
				<view class="flex-row-space-between">
					<view class="sTitle">
						推荐路线
					</view>
					<view @click="changePathCity1Click()" class="flex-row-flex-end">
						<view class="sTitle1">
							全部路线
						</view>
						<uni-icons type="right" size="16" color="#999999"></uni-icons>
					</view>
				</view>
				<view class="flex-row-flex-start flex-wrap">
					<view v-for="(item,index) in pathList" :key="index">
						<view @click="sItemClick(item)" class="sItem flex-row-center">
							<view class="sItem1 ">
								{{item.start_name}}
							</view>
							<image src="/static/index/jt.png" style="width: 24rpx;margin: 0 6rpx;" mode="widthFix"></image>
							<view class="sItem1 ">
								{{item.end_name}}
							</view>
						</view>
					</view>
				</view>
			
			</view>

			<!-- <view class="cityView flex-row-space-between">
				<view class=" flex-row-flex-start">
					<view class="line1">

					</view>
					<view class="title1">
						已开通城市
					</view>
				</view>
				<view @click="location()" class="dingwei flex-row-center">
					<image class="image7" src="/static/index/7.png" mode=""></image>
				</view>
			</view>
			<view class="flex-wrap flex-row-flex-start" style="margin: 0 30rpx;">
				<view v-for="(item,index) in cityData.open_city" :key="index">
					<view class="item flex-row-center">
						{{item.city_name}}
					</view>
				</view>
			</view>

			<view class="cityView flex-row-space-between">
				<view class=" flex-row-flex-start">
					<view class="line1">

					</view>
					<view class="title1">
						筹备中城市
					</view>
				</view>
			</view>
			<view class="flex-wrap flex-row-flex-start" style="margin: 0 30rpx;">
				<view v-for="(item,index) in cityData.preparation_city" :key="index">
					<view class="item1 flex-row-center">
						{{item.city_name}}
					</view>
				</view>
			</view> -->

		</view>
		<uni-popup ref="loginPopup">
			<view class="loginView flex-column-flex-start">
				<view @click="closeImageClick()" class="closeImage flex-row-flex-end">
				</view>
				<view class="flex-column-flex-start1">
					<image class="loginImage" src="/static/login/logo.png" mode=""></image>
					<view class="loginTitle">
						为了获取周边信息,需要获取您的地理位置
					</view>
					<view class="flex-row-center">
						<button @click="disagreeClick()" class="loginButton2">不同意</button>
					<!-- 	<button v-if="isTong" class="loginButton2" open-type="agreePrivacyAuthorization"
							@agreeprivacyauthorization='agreeprivacyauthorization'>同意</button> -->
							<button v-if="isTong" @click="disagreeClick1()" class="loginButton2">同意</button>
						<button v-if="!isTong" @click="disagreeClick1()" class="loginButton2">同意</button>
					</view>


					<view class="xyTitle flex-row-center">
						<image @click="isTongClick()" v-if="isTong" src="/static/common/xz.png" mode=""></image>
						<image @click="isTongClick()" v-if="!isTong" src="/static/common/wxz.png" mode=""></image>
						<text @click="isTongClick()" class="">
							同意
						</text>
	<text @click="toUrl('/pages/personalCenter/richText?title=用户协议')" class="baseColor">
						用户协议
					</text>
							<text class="">
						和
					</text>
					<text @click="toUrl('/pages/personalCenter/richText?title=隐私协议')" class="baseColor">
						隐私协议
					</text>
					</view>
				<!-- 	<text style="margin-top: 10rpx;" @click="goToPrivacy()" class="baseColor">
						{{privacySetting.privacyContractName}}
					</text> -->
				</view>

			</view>
		</uni-popup>
		<u-picker @cancel="modeCancel()" :show="show" :columns="columns" @confirm='click' keyName="label"></u-picker>
	</view>
</template>

<script>
	var QQMapWX = require('@/utils/qqmap-wx-jssdk.min.js');
	// 实例化API核心类
	var qqmapsdk = new QQMapWX({
		key: 'JKYBZ-NQRW4-Y47U6-KLJJT-HLGYQ-B2B4O' // 必填
	});
	import {
		getOpenCity,
		slideshow,
		getCityByLngAndLat,
		getStartPrice,
		path
	} from '@/api/index.js'
	export default {
		components: {},
		computed: {

		},
		data() {
			return {
				pathList:[],
				slideshowList:[],
				tabsIndex: 1,
				tabsList: [{
						name: '短途',
						status: "打车"
					},
					{
						name: '长途',
						status: "10"
					},



				],
				privacySetting: {},
				isShow: false,
				isTong: false,
				qdInfo: {
					city: '',
					latitude: '',
					longitude: '',
					address: ""
				},
				zdInfo: {
					city: '',
					latitude: '',
					longitude: '',
					address: ""
				},
				show: false,
				columns: [
					['1名司机', '2名司机', '3名司机', '4名司机', '5名司机', '6名司机', '7名司机', '8名司机']
				],
				cityData: {
					open_city: [],
					preparation_city: []
				},
				num: 1,
				ylInfo: {
					latitude: '',
					longitude: '',
					// city: '定位中...',
					city: '明途出行',
					address: ""
				},

				userInfo: null,
				border: false,
				startPrice: {
					start_price: 0
				},

				friendInfo: {
					friend_name: '',
					friend_mobile: '',
					who_pay: 20,
				},
				isOpen: true,
				isOpen1: true,
				
				
				
				
				// 顺风车模块数据
				tailwindQdInfo:{
					id:'',
					city: '',
					latitude: '',
					longitude: '',
					address: ""
				},
				tailwindZdInfo:{
					id:'',
					city: '',
					latitude: '',
					longitude: '',
					address: ""
				}

			}
		},
		onShow() {


			// uni.$on("cityName", res => {
			// 	this.city = res.city;
			// 	// 清除监听
			// 	uni.$off('cityName');
			// })
			var token = uni.getStorageSync('token')
			console.log(token)
			if (!token) {
				// this.location()
			} else {
				if(!this.tabsIndex){
					this.location()
				}else{
					this.path()
				}
				
				
				// if (this.ylInfo.city == '定位中...') {

				// 	this.location()
				// }
			}


		},

		onLoad() {
			// uni.navigateTo({
			// 	url:'/pages/login/login'
			// })

		this.slideshow()
		
		},
		mounted(){
			uni.$on('update:tailwindQdInfo',(id,city,latitude,longitude,address)=>{
				this.tailwindQdInfo.id = id
				this.tailwindQdInfo.city = city
				this.tailwindQdInfo.latitude = latitude
				this.tailwindQdInfo.longitude = longitude
				this.tailwindQdInfo.address = address
				this.tailwindZdInfo.id = ''
				this.tailwindZdInfo.city = ''
				this.tailwindZdInfo.latitude = ''
				this.tailwindZdInfo.longitude = ''
				this.tailwindZdInfo.address = ''
			})
			uni.$on('update:tailwindZdInfo',(id,city,latitude,longitude,address)=>{
				this.tailwindZdInfo.id = id
				this.tailwindZdInfo.city = city
				this.tailwindZdInfo.latitude = latitude
				this.tailwindZdInfo.longitude = longitude
				this.tailwindZdInfo.address = address
			})
		},
		onUnload() {
			uni.$off('update:tailwindQdInfo')
			uni.$off('update:tailwindZdInfo')
		},

		methods: {
			changePathCity1Click(){
				var token = uni.getStorageSync('token')
				
				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				uni.navigateTo({
					url:'changePathCity1'
				})
			},
			sItemClick(item) {
				this.tailwindQdInfo.id = item.start_location_id
				this.tailwindQdInfo.city = item.start_name
				this.tailwindZdInfo.id = item.end_location_id
				this.tailwindZdInfo.city = item.end_name
				uni.navigateTo({
					url:`/pages/index/findHitchRide?tailwindQdInfo=${JSON.stringify(this.tailwindQdInfo)}&tailwindZdInfo=${JSON.stringify(this.tailwindZdInfo)}`
				})
			},
			
			path(){
				var that = this
				var data = {
					page: 1,
					limit: 999,
				}
				path(data)
					.then(res => {
						this.pathList = res.data.data
					})
			},
			slideshow(){
				slideshow({
				
					})
					.then(res => {
						this.slideshowList = res.data
					})
			},
			// 顺风车选择地址
			changePathCity(type){
				var token = uni.getStorageSync('token')
				
				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				var url =`/pages/index/changePathCity?type=${type}`
				if(type=='end'){
					if(!this.tailwindQdInfo.id){
						this.showToast('请先选择起点')
						return
					}
					url =`/pages/index/changePathCity?type=${type}&start_id=${this.tailwindQdInfo.id}`
				}
				// const url = type=='satrt'?`/pages/index/changePathCity?type=${type}`:`/pages/index/changePathCity?type=${type}&start_id=${this.tailwindQdInfo.id}`
				uni.navigateTo({
					url
				})
			},
			//顺风车列表
			findHitchRide(){
				if(!this.tailwindQdInfo.id) return this.showToast('请输入起点')
				if(!this.tailwindZdInfo.id) return this.showToast('请输入终点')
				uni.navigateTo({
					url:`/pages/index/findHitchRide?tailwindQdInfo=${JSON.stringify(this.tailwindQdInfo)}&tailwindZdInfo=${JSON.stringify(this.tailwindZdInfo)}`
				})
			},
			
			
			
			downwindListClick() {
				if (!this.qdInfo.address.length) {
					this.showToast('请输入起点')
					return
				}

				if (!this.zdInfo.address.length) {
					this.showToast('请输入终点')
					return
				}
				uni.setStorageSync('qdInfo', this.qdInfo)
				uni.setStorageSync('zdInfo', this.zdInfo)
				uni.navigateTo({
					url: 'downwindList'
				})
			},
			tabClick(e) {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				this.tabsIndex = e.index
				if(!this.tabsIndex){
					this.location()
				}
			},
			// 打开隐私协议
			goToPrivacy() {
				wx.openPrivacyContract({
					success: () => {
						console.log('打开成功');
					}, // 打开成功
					fail: () => {
						uni.showToast({
							title: '打开失败，稍后重试',
							icon: 'none'
						})
					} // 打开失败
				})
			},

			agreeprivacyauthorization(e) {
				if (!this.isTong) {

					this.showToast('请同意协议')

					return

				}
				console.log(e)
				this.location1()
				this.$refs.loginPopup.close('center')
				uni.setStorageSync('privacyIsShow', true)


			},
			disagreeClick() {
				this.$refs.loginPopup.close('center')
				// uni.setStorageSync('privacyIsShow', false)
				uni.setStorageSync('isLocation', 0)
				
			},
			disagreeClick1() {

				if (!this.isTong) {

					this.showToast('请先同意协议')

					return

				}
				uni.setStorageSync('isLocation', 1)
				this.$refs.loginPopup.close('center')
				// uni.setStorageSync('privacyIsShow', true)
				this.location()
			},
			toUrl(url) {
				uni.navigateTo({
					url: url
				})
			},
			isTongClick() {
				this.isTong = !this.isTong
			},
			isOpen_city1(city) {
				// var _this = this
				// var isOpen = false
				// this.cityData.open_city.forEach(item => {

				// 	if (city == item.city_name) {
				// 		isOpen = true
				// 	}

				// })
				// _this.isOpen = isOpen
				// if (!_this.isOpen) {
				// 	setTimeout(() => {
				// 		_this.showToast('请选择已开通城市')
				// 	}, 100)
				// }


			},

			isOpen_city(city, type) {
				var _this = this
				var isOpen = false
				this.cityData.open_city.forEach(item => {

					if (city == item.city_name) {
						isOpen = true
					}

				})
				_this.isOpen1 = isOpen


				if (!_this.isOpen1) {

					// if (type) {
					// 	setTimeout(() => {
					// 		_this.showToast('当前城市未开通')
					// 	}, 100)

					// } else {
					// 	setTimeout(() => {
					// 		_this.showToast('请选择已开通城市')
					// 	}, 100)

					// }

				}
			},



			exchange(type) {
				if(type=='dache'){ //打车切换起点终点
					var exchange = {
						latitude: '',
						longitude: '',
						city: '',
						address: ""
					}
					exchange = this.qdInfo
					this.qdInfo = this.zdInfo
					this.zdInfo = exchange
				}else{ //顺风车切换起点终点
					var exchange = {
						latitude: '',
						longitude: '',
						city: '',
						address: ""
					}
					exchange = this.tailwindQdInfo
					this.tailwindQdInfo = this.tailwindZdInfo
					this.tailwindZdInfo = exchange
				}
			},
			getStartPrice() {
				getStartPrice({
						lat: this.qdInfo.latitude,
						lng: this.qdInfo.longitude,
						city: this.qdInfo.city
					})
					.then(res => {
						this.startPrice = res.data
					})
			},
			reverseGeocoder(latitude, longitude, type) {
				//逆地址解析  坐标转地址信息
				qqmapsdk.reverseGeocoder({
					//Object格式
					location: {
						latitude: latitude,
						longitude: longitude
					},
					success: function(res) { //成功后的回调
						// console.log(res)
					},
				});
			},
			getCityByLngAndLat(latitude, longitude, type) {
				var that = this
				getCityByLngAndLat({
						lat: latitude,
						lng: longitude
					})
					.then(res => {
						console.log(res)
						const mapdata = res.data.addressComponent;
						const address = res.data.formatted_address;
						console.log(type == 2)

						if (type == 2) {
							if (mapdata.province == '北京市' || mapdata.province == '天津市' || mapdata.province == '上海市' ||
								mapdata.province == '重庆市') {
								that.ylInfo.city = mapdata.province;
								that.qdInfo.city = mapdata.province;
							} else {
								that.ylInfo.city = mapdata.city;
								that.qdInfo.city = mapdata.city;
							}
							uni.setStorageSync('ylCity', that.ylInfo.city)
							if (mapdata.neighborhood.name.length) {
								that.ylInfo.address = mapdata.neighborhood.name;
								that.qdInfo.address = mapdata.neighborhood.name;
							} else {
								that.ylInfo.address = address;
								that.qdInfo.address = address;
							}
							uni.setStorageSync('city', that.ylInfo.city)
							that.getOpenCity()

							uni.setStorageSync('ylInfo', that.ylInfo)
							that.getStartPrice()
						} else {
							if (mapdata.province == '北京市' || mapdata.province == '天津市' || mapdata.province == '上海市' ||
								mapdata.province == '重庆市') {
								if (type) {
									that.zdInfo.city = mapdata.province


								} else {
									that.qdInfo.city = mapdata.province
									that.getStartPrice()
								}

							} else {
								if (type) {
									that.zdInfo.city = mapdata.city

								} else {
									that.qdInfo.city = mapdata.city
									that.getStartPrice()
								}
							}

							if (type) {

								that.isOpen_city1(that.zdInfo.city, 1)
							} else {

								that.isOpen_city(that.qdInfo.city, 0)

							}
						}

						// 		if (mapdata.province == '北京市' || mapdata.province == '天津市' || mapdata.province == '上海市' ||
						// 			mapdata.province == '重庆市') {
						// 			that.ylInfo.city = mapdata.province;
						// 			that.qdInfo.city = mapdata.province;
						// 		}else{
						// 			that.ylInfo.city = mapdata.city;
						// 			that.qdInfo.city = mapdata.city;
						// 		}
						// 	uni.setStorageSync('city', that.ylInfo.city)
						// 		that.getOpenCity()
						// 		// that.qdInfo.address = address;
						// 		if (mapdata.neighborhood.name.length) {
						// 			that.ylInfo.address = mapdata.neighborhood.name;
						// 			that.qdInfo.address = mapdata.neighborhood.name;
						// 		} else {
						// 			that.ylInfo.address = address;
						// 			that.qdInfo.address = address;
						// 		}
						// 		uni.setStorageSync('ylInfo', that.ylInfo)
						// 		that.getStartPrice()
					})
					.catch(err => {

					})
			},

			location1() {
				var that = this
				// uni.getLocation({
				// 	type: 'gcj02',
				// 	geocode: true,
				uni.getLocation({
					type: 'gcj02',
					success: function(res) {
						// console.log(res)
						that.ylInfo.latitude = res.latitude;
						that.ylInfo.longitude = res.longitude;
						that.qdInfo.latitude = res.latitude;
						that.qdInfo.longitude = res.longitude;
						that.getCityByLngAndLat(res.latitude, res.longitude, 2)
						// getCityByLngAndLat({
						// 		lat: res.latitude,
						// 		lng: res.longitude
						// 	})
						// 	.then(res => {

						// 		const mapdata = res.data.addressComponent;
						// 		const address = res.data.formatted_address;
						// 		if (mapdata.province == '北京市' || mapdata.province == '天津市' || mapdata.province == '上海市' ||
						// 			mapdata.province == '重庆市') {
						// 			that.ylInfo.city = mapdata.province;
						// 			that.qdInfo.city = mapdata.province;
						// 		}else{
						// 			that.ylInfo.city = mapdata.city;
						// 			that.qdInfo.city = mapdata.city;
						// 		}
						// 	uni.setStorageSync('city', that.ylInfo.city)
						// 		that.getOpenCity()
						// 		// that.qdInfo.address = address;
						// 		if (mapdata.neighborhood.name.length) {
						// 			that.ylInfo.address = mapdata.neighborhood.name;
						// 			that.qdInfo.address = mapdata.neighborhood.name;
						// 		} else {
						// 			that.ylInfo.address = address;
						// 			that.qdInfo.address = address;
						// 		}
						// 		uni.setStorageSync('ylInfo', that.ylInfo)
						// 		that.getStartPrice()
						// 	})
						// 	.catch(err => {

						// 	})


					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			location() {


				// if (wx.getPrivacySetting) {
				// 	wx.getPrivacySetting({
				// 		success: res => {
				// 			this.privacySetting = res
				// 			console.log("是否需要授权：", res.needAuthorization, "隐私协议的名称为：", res
				// 				.privacyContractName)
				// 			if (res.needAuthorization) {
				// 				this.$refs.loginPopup.open('center')
				// 				return

				// 			} else {


				// 			}
				// 		},
				// 		fail: () => {},
				// 		complete: () => {},
				// 	})
				// } else {
				// 	// 低版本基础库不支持 wx.getPrivacySetting 接口，隐私接口可以直接调用

				// }
// this.$refs.loginPopup.open('center')
// var isLocation = uni.getStorageSync('isLocation')
// if(isLocation){
	this.location1()
// }else{
// 	this.$refs.loginPopup.open('center')
// }
				
			},

			showToast(title) {
				uni.showToast({
					title: title,
					icon: 'none'
				})
			},
			//呼叫
			orderDetailClick() {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				if (!this.qdInfo.address.length) {
					this.showToast('请输入起点')
					return
				}
				if (!this.zdInfo.address.length) {
					this.showToast('请输入终点')
					return
				}
				// if (!this.isOpen || !this.isOpen1) {

				// 	setTimeout(() => {
				// 		this.showToast('请选择已开通城市')
				// 	}, 100)

				// 	return
				// }
				uni.setStorageSync('qdInfo', this.qdInfo)
				uni.setStorageSync('zdInfo', this.zdInfo)
				uni.setStorageSync('friendInfo', this.friendInfo)
				uni.setStorageSync('startPrice', this.startPrice)
				uni.setStorageSync('driver_number', this.num)
				uni.navigateTo({
					url: 'orderDetail'
				})
			},
			addressClick(type) {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				// uni.navigateTo({
				// 	url: 'address?type=' + type
				// })
				var that = this
				uni.chooseLocation({
					success: (res) => {
						// console.log(res)
						if (type) {
							that.zdInfo.address = res.name
							that.zdInfo.latitude = res.latitude;
							that.zdInfo.longitude = res.longitude;
						} else {
							that.qdInfo.address = res.name
							that.qdInfo.latitude = res.latitude;
							that.qdInfo.longitude = res.longitude;
						}
						that.getCityByLngAndLat(res.latitude, res.longitude, type)
						// var reg = /.+?(省|市|自治区|自治州|县|区)/g;
						// var addressList = res.address.match(reg)
						// console.log(res.address + ': ',addressList);
						// if (addressList[0] == '北京市' || addressList[0] == '天津市' || addressList[0] == '上海市' ||
						// 	addressList[0] == '重庆市') {
						// 	if (type) {
						// 		that.zdInfo.city = addressList[0]


						// 	} else {
						// 		that.qdInfo.city = addressList[0]
						// 		that.getStartPrice()
						// 	}
						// } else {
						// 	if (type) {
						// 		that.zdInfo.city = addressList[1]

						// 	} else {
						// 		that.qdInfo.city = addressList[1]
						// 		that.getStartPrice()
						// 	}
						// }

						// if (type) {

						// 	that.isOpen_city1(that.zdInfo.city)
						// } else {

						// 	that.isOpen_city(that.qdInfo.city,0)

						// }
					},
					fail: (error) => {
						console.log(error)
					}
				});
			},
			click(e) {
				// console.log(e);
				// this.city = e.value[0]
				this.num = e.indexs[0] + 1
				this.show = false
			},
			modeCancel() {
				this.show = false
			},
			passengerInfoClick() {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				if (!this.qdInfo.address.length) {
					this.showToast('请输入起点')
					return
				}
				// if (!this.isOpen || !this.isOpen1) {



				// 	setTimeout(() => {
				// 		this.showToast('请选择已开通城市')
				// 	}, 100)

				// 	return
				// }
				if (!this.zdInfo.address.length) {
					this.showToast('请输入终点')
					return
				}
				uni.setStorageSync('qdInfo', this.qdInfo)
				uni.setStorageSync('zdInfo', this.zdInfo)
				uni.setStorageSync('startPrice', this.startPrice)
				uni.setStorageSync('driver_number', this.num)
				uni.navigateTo({
					url: 'passengerInfo'
				})
			},
			descriptionClick() {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				uni.navigateTo({
					url: 'description'
				})
			},
			getOpenCity() {
				// var that = this
				// getOpenCity({

				// 	})
				// 	.then(res => {
				// 		that.cityData = res.data
				// 		that.isOpen_city(that.qdInfo.city, 1)
				// 	})
				// 	.catch(err => {

				// 	})
			},
			handleLocation() {
				// uni.navigateTo({
				// 	url: '/pages/index/city'
				// })
			},
			toLogin() {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
			},
			clickLeft() {
				var token = uni.getStorageSync('token')

				if (!token) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				uni.navigateTo({
					url: '/pages/personalCenter/personalCenter'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {}

	.input-view {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		// width: 500rpx;
		flex: 1;
		// background-color: #f8f8f8;
		// height: $nav-height;
		border-radius: 15px;
		padding: 0 15px;
		flex-wrap: nowrap;
		margin: 7px 0;
		// line-height: $nav-height;
	}

	.navTitle {
		font-size: 32rpx;
		// font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.title {
		margin-left: 30rpx;
		padding-top: 30rpx;
		// padding-top: 150rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
	}

	.view1 {
		padding: 30rpx;
		margin: 56rpx 30rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(88, 188, 124, 0.2);
		border-radius: 30rpx 30rpx 30rpx 30rpx;
	}

	.image1 {
		margin-right: 6rpx;
		width: 32rpx;
		height: 32rpx;
	}

	.num {
		font-size: 28rpx;
		font-family: Source Han Sans CN-Regular, Source Han Sans CN;
		font-weight: 400;
		color: #3D3D3D;
	}

	.image2 {
		margin-left: 6rpx;
		width: 12rpx;
		height: 12rpx;
	}

	.money {
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
	}

	.image3 {
		margin-left: 6rpx;
		width: 28rpx;
		height: 28rpx;
	}

	.image4 {
		width: 36rpx;
		height: 36rpx;
		margin-right: 20rpx;
	}

	.address {
		font-size: 32rpx;
		font-family: Source Han Sans CN-Medium, Source Han Sans CN;
		font-weight: 500;
		color: #333333;
	}

	.addressView {
		margin-top: 40rpx;
	}

	.image6 {
		margin-top: 40rpx;
		margin-right: 12rpx;
		margin-left: 12rpx;
		width: 36rpx;
		height: 36rpx;
	}

	.button {
		margin-top: 40rpx;
		width: 300rpx;
		height: 76rpx;
		border-radius: 38rpx;
		opacity: 1;
		border: 2rpx solid $base-color;
		font-size: 28rpx;
		font-family: Source Han Sans CN-Medium, Source Han Sans CN;
		// font-weight: 500;
		color: $base-color;
	}

	.button1 {
		margin-top: 40rpx;
		width: 300rpx;
		height: 76rpx;
		background: $base-color;
		border-radius: 38rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN-Medium, Source Han Sans CN;
		// font-weight: 500;
		color: #FFFFFF;
	}

	.button2 {

		margin-top: 30rpx;
		width: 600rpx;
		height: 76rpx;
		background: $base-color;
		border-radius: 38rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN-Medium, Source Han Sans CN;
		// font-weight: 500;
		color: #FFFFFF;
	}

	.line1 {
		margin-right: 10rpx;
		margin-left: 30rpx;
		width: 10rpx;
		height: 28rpx;
		background: $base-color;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		opacity: 1;
	}

	.title1 {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #3D3D3D;
	}

	.dingwei {
		margin-right: 30rpx;
		width: 76rpx;
		height: 76rpx;
		background: #FFFFFF;
		border-radius: 50%;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
		opacity: 1;
	}

	.image7 {
		width: 36rpx;
		height: 36rpx;
	}

	.cityView {
		margin-top: 40rpx;
	}

	.item {
		margin-top: 40rpx;
		margin-right: 30rpx;
		width: 150rpx;
		height: 64rpx;
		background: #26D36033;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $base-color;
	}

	.item1 {
		margin-top: 40rpx;
		margin-right: 30rpx;
		width: 150rpx;
		height: 64rpx;
		background: #EEEEEE;
		border-radius: 32rpx;
		opacity: 1;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
	}

	.loginView {
		padding: 30rpx 0;
		width: 567rpx;
		// height: 580rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
	}

	.closeImage {
		width: 34rpx;
		height: 34rpx;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}

	.loginImage {
		margin-top: 20rpx;
		width: 268rpx;
		height: 183rpx;
	}

	.loginTitle {
		margin-top: 32rpx;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: $base-color;
	}

	.loginTitle1 {
		// margin-top: 38rpx;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #000;
	}

	.loginButton {
		margin-top: 10rpx;
		width: 360rpx;
		height: 64rpx;
		background: $base-color;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		color: #FFFFFF;
	}

	.loginButton2 {
		margin: 0 10rpx;
		margin-top: 40rpx;
		width: 200rpx;
		height: 64rpx;
		background: $base-color;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		color: #FFFFFF;
	}

	.loginButton1 {
		margin-top: -64rpx;
		width: 360rpx;
		height: 64rpx;
		background: #00000000;
		border-radius: 32rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		color: #FFFFFF;
		z-index: 999;
	}

	.xzImage {
		margin-top: -34rpx;
		width: 28rpx;
		height: 28rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.xieyi {
		margin-left: 20rpx;
		font-size: 22rpx;
		font-family: PingFang SC;
		// font-weight: 500;
		color: #000000;
	}

	.xyTitle {
		margin-top: 20px;
		font-size: 14px;
		font-weight: normal;
		text-transform: uppercase;
		letter-spacing: 0em;

		/* 我已阅读并同意 */
		color: #999999;

		image {
			margin-right: 4px;
			width: 16px;
			height: 16px;
		}
	}
	.sTitle{
		font-family: PingFang SC, PingFang SC;
		font-weight: 550;
		font-size: 28rpx;
		color: #333333;
	}
	.sTitle1{
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
	}
	.sItem{
		margin-top: 20rpx;
		margin-right: 20rpx;
		padding: 0rpx 14rpx ;
		height: 64rpx;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		border: 2rpx solid #EEEEEE;
	}
	.sItem1{
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #333333;
	}
</style>